package net.aetherial.context.grounding.analyzers;

import net.aetherial.context.grounding.classifiers.*;
import net.aetherial.context.grounding.estimators.*;
import net.aetherial.context.grounding.loggers.*;

/**
 * Abstract class for constucting analyzers.
 */

public abstract class Analyzer 
{
	protected Classifier classifier;
	protected Estimator estimator;
	protected Logger logger;
	
	/**
	 * Sets the analyzer's classifier.
	 * @param c		Classifier.
	 */

	public void setClassifier (Classifier c)
	{
		classifier = c;
	}

	/**
	 * Set's the analyzer's estimator.
	 * 
	 * @param e		Estimator.
	 */
	
	public void setEstimator (Estimator e)
	{
		estimator = e;
	}

	/**
	 * Sets the analyzer's logger.
	 * 
	 * @param l		Logger.
	 */
	
	public void setLogger (Logger l)
	{
		logger = l;
	}
	
	/**
	 * Processes a conversation using the set classifier and estimator and logs the results using the logger.
	 * 
	 * @param sender			Sender/speaker.
	 * @param contribution		Conversational unit.
	 * @param score				Coded score (optional).
	 */
	
	public void process (String sender, String contribution, double score) 
	{
		System.out.println ("Analyzer, Processing: " + contribution);

		if (estimator != null)
			logger.logEstimate (estimator.estimate (sender, contribution, score));
		
		if (classifier != null)
			logger.logClassification (classifier.classify (contribution));
	}

	/**
	 * Resets the classifiers and estimators for a new turn.
	 */
	
	public void reset ()
	{
		if (estimator != null)
			estimator.reset ();
		
		/* if (classifier != null);
			classifier.reset (); */
	}
}
